/*********************************************************
          File Name:10.28.cpp
          Author: Abby Cin
          Mail: abbytsing@gmail.com
          Created Time: Mon 14 Mar 2016 07:13:59 PM CST
**********************************************************/

#include <iostream>
#include <algorithm>
#include <iterator>
#include <vector>
#include <list>

using namespace std;

int main()
{
    vector<int> vi{1, 2, 3, 4, 5, 6, 7, 8, 9};
    list<int> l1, l2, l3;

    copy(vi.begin(), vi.end(), back_inserter(l1));
    copy(vi.begin(), vi.end(), front_inserter(l2));
    copy(vi.begin(), vi.end(), inserter(l3, l3.begin()));

    auto lambda = [](list<int> &li) {
        for(const auto &x: li)
            cout << x << " ";
    };

    cout << "back_inserter\n";
    lambda(l1);

    cout << "\nfront_inserter\n";
    lambda(l2);

    cout << "\ninserter\n";
    lambda(l3);

    cout << '\n';

    return 0;
}
